<template>
  <div class="main">
    <div class="title_aa">
      <div class="title_my" @click="toSign()">
        <p class="title_my_jf">我的积分</p>
        <div class="title_my_jfs">{{ userInfo.memberPoints }}</div>
        <div class="title_m">
          普通积分商城
          <i>></i>
        </div>
      </div>
      <div class="title_points">
        <div class="jifen">精品专区积分</div>
        <div class="bb">{{ userInfo.highQualityPoints }}</div>
        <div class="title_mys">
          <span class="mys_jl" @click="toRecord()">积分记录</span>
          <span class="mys_dd" @click="toOrder()">积分订单</span>
        </div>
      </div>
    </div>
    <div class="title_bb">
      <div class="title_bbs_a" @click="goMySign">
        <div class="bbs_a_left">
          <p>签到领积分</p>
          <div class="ji">每月最高可得8500积分</div>
        </div>
        <img class="Img" src="../../assets/image/rili.png" alt />
      </div>
      <div class="title_bbs_a" @click="goCoin">
        <div class="bbs_a_left">
          <p>积分兑金币</p>
          <div class="ji">金币可抵扣普药货款</div>
        </div>
        <img class="Img" src="../../assets/image/monly.png" alt />
      </div>
    </div>
    <div class="title_desc">
      <p class="bigTitle">活动规则</p>
      <div class="desc" :class="{ desc: isHide, noDesc: !isHide }">
        <div class="single">
          1、单笔精品订单积分达到1000积分及以上，可享受对应积分的任何一件礼品；
        </div>
        <div class="single">
          2、精品积分可以进行积分累计。但累计积分必须满5000积分及以上才能兑换相应礼品。
        </div>
        <p class="smalltitle">提示：</p>
        <div class="single">
          1、凡在药易购精品专区购买产品的客户均可获得精品积分，1元=1精品分；
        </div>
        <div class="single">
          2、累积的精品积分每季度末自动清零，下季度从零累积，请及时兑换礼品累积的精品积分每季度末自动清零，下季度从零累积，请及时兑换礼品哦！兑换的礼品在提交订单15天内发货！
        </div>
      </div>
      <div class="btn">
        <p v-show="isHide" @click="isHide = false">
          收起
          <van-icon name="arrow-up" />
        </p>
        <p v-show="!isHide" @click="isHide = true">
          展开
          <van-icon name="arrow-down" />
        </p>
      </div>
    </div>
    <div class="main_center">
      <van-list v-model="isLoading" :finished="finished" finished-text="没有更多了" @load="getPaging">
        <div class="life">
          <div class="life_item" v-for="(item, i) in goods" :key="i" @click="toDetails1(item)">
            <img class="imgs" :src="item.img" alt />
            <div class="item_main">
              <div class="name">{{ item.goodsName }}</div>
              <div class="car">
                <div class="mol">
                  <img src="../../assets/image/moliy.png" alt />
                  <span>{{ item.point }}积分</span>
                </div>
                <img src="../../assets/image/goo.png" alt />
              </div>
            </div>
          </div>
        </div>
      </van-list>
      <areaPop v-show="show" :click_pop="click_pop" @changeDia="changeDia"></areaPop>
    </div>
  </div>
</template>
<script>
import areaPop from '../../components/areaPop'
import url from '../../axios/apiUrl'
import { postRequest } from '../../api/index'
import { getRequest } from '../../api/indexGet'
export default {
  data() {
    return {
      userInfo: {},
      goods: [],
      show: false,
      click_pop: {},
      pageNumber: '',
      type: 1,
      category: 0,
      pageNum: 1,
      finished: false,
      isLoading: false,
      isHide: false,
    }
  },
  components: {
    areaPop,
  },
  created() {
    // 获取用户个人信息
    getRequest(url.pointsInfo).then((res) => {
      if (res.data.code == '000000') {
        this.userInfo = res.data.content
        if (this.userInfo.signNumber >= 0 && this.userInfo.signNumber < 7) {
          this.getPoints = 50
        } else if (
          this.userInfo.signNumber >= 7 &&
          this.userInfo.signNumber < 14
        ) {
          this.getPoints = 150
        } else if (
          this.userInfo.signNumber >= 14 &&
          this.userInfo.signNumber < 21
        ) {
          this.getPoints = 300
        } else if (
          this.userInfo.signNumber >= 21 &&
          this.userInfo.signNumber <= 31
        ) {
          this.getPoints = 500
        }
      }
    })
  },

  methods: {
    getPaging(page) {
      if (page) this.pageNum = page
      getRequest(url.pointsGoods + '/1/0/' + this.pageNum)
        .then((res) => {
          if (res.data.code == '000000') {
            if (this.pageNum == 1) {
              this.goods = []
            }
            this.pageNum++
            this.isLoading = false
            this.goods = this.goods.concat(res.data.content.list)
            if (this.goods.length == res.data.content.page.total) {
              this.finished = true
            } else {
              this.finished = false
            }
          }
        })
        .catch((error) => {
          console.log(error)
        })
    },
    toGiftCar() {
      this.$router.push('/boutiquePointsCar')
    },
    toSign() {
      this.$router.push('/pointsMall')
    },
    // 跳转商品详情
    toDetails1(item) {
      this.$router.push({
        path: '/pointsDetails',
        query: { goodsId: item.goodsId, type: 1 },
      })
    },
    // 点击弹窗
    showPopup(item) {
      this.click_pop = item
      this.show = true
      this.clickData = this.goods
    },
    changeDia(bool) {
      this.show = bool
    },
    // 跳转积分订单
    toOrder() {
      this.$router.push('/pointsOrder')
    },
    // 跳转积分商城
    goMySign() {
      // this.$router.push("/mySign");
      window.location.href = this.pathURL + 'nativeApp/mySign'
    },
    // 跳精品兑金币
    goCoin() {
      window.location.href = this.pathURL + 'nativeApp/GoldCoin'
    },
    // 跳转到积分记录
    toRecord() {
      window.location.href = this.pathURL + 'nativeApp/IntegralRecord'
    },
  },
}
</script>
<style lang="less" scoped>
.main {
  padding: 0;
  margin: 0;
  width: 100vw;
  height: auto;
  display: block;
  .title_aa {
    display: flex;
    justify-content: space-around;
    align-items: center;
    color: #fff;
    margin-bottom: 40px;
    .title_my {
      width: 240px;
      height: 158px;
      background-color: #eeb476;
      border-radius: 20px;
      align-items: center;
      margin-right: 14px;
      color: #fff;
      .title_my_jf {
        font-weight: 500;
        font-size: 0.22rem;
        color: #ffffff;
        padding-left: 12px;
      }
      .title_my_jfs {
        font-weight: bold;
        font-size: 0.46rem;
        color: #ffffff;
        padding-left: 12px;
      }
      .title_mys {
        color: #ffffff;
      }
      .title_m {
        padding-left: 12px;
        i {
          font-weight: bold;
          font-size: 26px;
          color: #ffffff;
        }
      }
    }
    .title_points {
      width: 422px;
      height: 200px;
      margin-top: 16px;
      margin-right: 12px;
      background: #fe550d;
      align-items: center;
      box-shadow: 0.1rem 0.1rem 0.04rem 0.06rem #fe550d;
      border-radius: 0.2rem;
      text-align: left;
      color: #fff;
      align-items: center;
      box-sizing: border-box;
      display: block;
      .jifen {
        color: #ffffff;
        margin-top: 26px;
        padding-left: 12px;
      }
      .bb {
        font-size: 0.36rem;
        font-weight: bold;
        color: #ffffff;
        margin-top: 18px;
        padding-left: 12px;
      }
      .title_mys {
        margin: 16px auto;
        color: #ffffff;
        padding-left: 12px;
        .mys_jl {
          border-right: 0.06rem solid#FFF;
          padding-right: 0.3rem;
          color: #ffffff;
        }
        .mys_dd {
          padding-left: 0.3rem;
          color: #ffffff;
        }
      }
    }
  }
  .title_bb {
    padding-left: 0.2rem;
    padding-right: 0.2rem;
    margin-top: 32px;
    display: flex;
    justify-content: space-between;
    text-align: center;
    .title_bbs_a {
      width: 328px;
      height: 140px;
      background: #ffffff;
      border: 1px solid #f1f2f6;
      border-radius: 10px;
      margin-left: 0.2rem;
      margin-right: 0.2rem;
      display: flex;
      justify-content: space-around;
      .Img {
        width: 180px;
        height: 140px;
        box-sizing: border-box;
        box-sizing: border-box;
      }
      .bbs_a_left {
        display: block;
        text-align: left;
        padding-left: 0.2rem;
        width: 50%;
        p {
          font-size: 0.3rem;
          font-family: PingFang SC;
          font-weight: bold;
          color: #343434;
        }
        .ji {
          font-size: 12px;
          font-family: PingFang SC;
          font-weight: 500;
          color: #666666;
          margin-top: -16px;
        }
      }
    }
  }
  .title_desc {
    margin: 15px auto;
    width: 646px;
    background: #ffffff;
    border: 1px solid #ff6407;
    border-radius: 10px;
    padding: 2px 20px 0;
    .single {
      color: #ff6407;
    }
    .bigTitle {
      font-size: 28px;
      font-weight: bold;
      color: #ff6407;
    }
    .smalltitle {
      font-size: 24px;
      font-weight: bold;
      color: #ff6407;
      line-height: 24px;
    }
    .noDesc {
      height: 150px;
      overflow: hidden;
      transition: all 1s ease;
    }
    .btn {
      margin-top: 20px;
      border-top: 1px solid #ececec;
      p {
        text-align: center;
        font-size: 20px;
        font-weight: 500;
        color: #999999;
        line-height: 36px;
      }
    }
  }
  .main_center {
    margin-top: 0.2rem;
    .life {
      background: #f1f2f6;
      .life_item {
        height: 252px;
        background: #ffffff;
        border-bottom: 0.2rem solid #f1f2f6;
        padding: 0.2rem;
        align-items: center;
        display: flex;
        justify-content: space-between;
        .imgs {
          width: 210px;
          height: 210px;
          padding: 0.2rem;
        }
        .item_main {
          width: 442px;
          margin-right: 26px;
          align-items: 0.48rem;
          .name {
            width: 5.87rem;
            height: 1.2rem;
            font-size: 26px;
            font-family: PingFang SC;
            font-weight: bold;
            color: #222222;
            // white-space: nowrap;
            // overflow: hidden;
            // text-overflow: clip;
          }

          .moliy {
            font-size: 0.22rem;
            font-family: PingFang SC;
            font-weight: 400;
            color: rgba(136, 136, 136, 0.8);
          }

          .car {
            width: 100%;
            height: 38px;
            line-height: 38px;
            align-items: center;
            display: flex;
            justify-content: space-between;
            margin-top: 20px;
            .mol {
              img {
                width: 0.29rem;
                height: 0.29rem;
                padding-right: 0.2rem;
              }
              margin: 0;
              font-size: 0.36rem;
              font-family: PingFang SC;
              font-weight: bold;
              color: #1fb808;
            }
            img {
              width: 0.46rem;
              height: 0.46rem;
            }
          }
        }
      }
    }
  }
}
</style>